package folder.model.network;

import java.util.ArrayList;
import java.util.List;

import folder.model.link.Link;
import folder.model.node.Node;
import folder.model.virtual.VirtualNetwork;

public class Network
{	
	// Network
	
	public static Network network(){ return new Network(); }
	public String toString(){ return nodes.toString();	}
	
	// Nodes
	
	private List< Node > nodes = new ArrayList< Node >();
	public List< Node > getNodes(){ return this.nodes; }
	public void addNode( Node node ){ this.nodes.add( node ); }
	public Node getNode( int identifier ){ return nodes.get( identifier ); }
	public int getNumberNodes(){ return this.nodes.size(); }
	
	// Links
	
	private List< Link > links = new ArrayList< Link >();
	public List< Link > getLinks(){ return this.links; }
	public void addLink( Link link ){ this.links.add( link ); }
	public Link getLink( int identifier ){ return links.get( identifier ); }
	public int getNumberLinks(){ return this.links.size(); }
	
	// Network path
			
	private NetworkPaths networkPaths = NetworkPaths.networkPaths( this );
	public void setPathsNodes( List< Node > nodes )
	{
		networkPaths.setPathsNodes( nodes );
	}
	public void setPathsNode( Node node )
	{
		networkPaths.setPathsNode( node );
	}
	public void setPathsNetwork()
	{
		networkPaths.setPathsNodes();
	}
	
	// // Network allocation
	
	private NetworkAllocation networkAllocation = NetworkAllocation.networkAllocation( this );	
	
	public boolean allocate( VirtualNetwork virtualNetwork )
	{
		return this.networkAllocation.allocate( virtualNetwork );
	}
	
	public void release( VirtualNetwork virtualNetwork )
	{
		this.networkAllocation.release( virtualNetwork );
	}
	
}
